<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page session ="true" %>
<%
String _user_id=(String)session.getAttribute("_user_id");
String _type=(String)session.getAttribute("_type");
session.setAttribute("_user_id", _user_id);
session.setAttribute("_type",_type);
if(_user_id==null || _user_id.length()==0 || _type==null || _type.length()==0){
	response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
	String newLocn = "logout.jsp";
	response.setHeader("Location",newLocn);
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Teacher Place</title>

<script type="text/javascript">
/****添加新条目***/
/******点击添加input输入框JS******/
function checkRowsLimit()
{
    var rowLimit = 100;
    var len=document.getElementById('filearea').rows.length;
    if(len==rowLimit)
    {
        alert('抱歉，为了您主页美观，只能添加这么多条目了。');
        return false;
    }
    else
    {
        return true;
    }
}
 
function addNewRow()
{
    var obj=document.getElementById('filearea');
    var len=document.getElementById('filearea').rows.length;
    var row=obj.insertRow(-1);
    var c0=row.insertCell(0);
    c0.innerHTML='Student ID<input type=text size="20" maxlength=15 name="studentid'+len+'" value="" onpropertychange=changeFlagValue()>  Score ';
    c0.align='right';
 
    var c1=row.insertCell(1);
    c1.innerHTML='<input type=text size=10 maxlength=50 name="count'+len+'" style="margin-left:1px;" value="" onpropertychange=changeFlagValue()>';
    c1.align='left';
 
    var c2=row.insertCell(2);
    c2.innerHTML='<a href="javascript:void(0)" onclick="removeRow(this)">Delete</a>';
    changeFlag = true;
    try
    {
        comm_set_page_height();
    }
    catch (e)
    {
    }
}
function removeRow(fontobj)
{
    if(confirm("确定取消该项吗?"))
    {
        var obj=document.getElementById('filearea');
        var n=fontobj.parentNode.parentNode.rowIndex;
        obj.deleteRow(n);
    }
}</script>
</head>
<body>
<h1>I think you are a teacher! ^_^ Please input students id and their scores</h1>
<form action="Addcounts" method="post">
<input type="hidden" name="_user_id" value="<%=_user_id%>"/> 
<input type="hidden" name="_type" value="<%=_type%>"/> 
    <table width="680" border="0"  id="filearea">
        <tr>
            <td align=right>Student ID<input type="text" onpropertychange=changeFlagValue() maxLength=15 size=20 name=studentid /> Score </td>
            <td align=left><input type="text"  style="MARGIN-LEFT: 1px" onpropertychange=changeFlagValue() maxLength=50 size=10 name=count /></td>
            <td><a href="#" onClick="if(checkRowsLimit()) {addNewRow();changeFlag=true}" title="点击后在上面添加的输入框">Add Student</a></td>
            <td><input type="submit" value="Submit" /></td>
        </tr>
    </table>
</form>
<a href="logout.jsp">Logout</a>
</body>
</html>